<template>
  <el-container>
    <el-header>
      <h1>传感器数据</h1>
    </el-header>
    <el-main>
      <el-table :data="sensorData" style="width: 100%">
        <el-table-column prop="id" label="ID" width="100" />
        <el-table-column prop="deviceId" label="设备ID" />
        <el-table-column prop="temperature" label="温度" />
        <el-table-column prop="humidity" label="湿度" />
        <el-table-column prop="lightIntensity" label="光照强度" />
        <el-table-column prop="co2Concentration" label="二氧化碳浓度" />
        <el-table-column prop="timestamp" label="时间戳" />
      </el-table>
    </el-main>
  </el-container>
</template>

<script>
import { mapState, mapActions } from 'vuex';

export default {
  computed: {
    ...mapState(['sensorData']),
  },
  methods: {
    ...mapActions(['fetchSensorData']),
  },
  mounted() {
    this.fetchSensorData();
  },
};
</script>